package com.duguo.dynamicmvc.factory.stage;

import com.duguo.dynamicmvc.factory.ControllerBuilder;
import com.duguo.dynamicmvc.factory.ControllerFactory;
import com.duguo.dynamicmvc.factory.WorkingModel;
import com.duguo.dynamicmvc.factory.utils.BeanUtils;

public class InjectionBeansStage implements Stage {

    public void execute(ControllerFactory controllerFactory) throws Exception {
    	WorkingModel workingModel=controllerFactory.getWorkingModel();
    	ControllerBuilder controllerBuilder=controllerFactory.getControllerBuilder();
    	Object controllerInstance=workingModel.getControllerInstance();
    	
    	controllerBuilder.getProcessorHolder().getControllerProcessor().injectionFeilds(controllerInstance);
        if(workingModel.isMultiActionController()){
        	BeanUtils.setFieldValue(controllerInstance, "controllerBuilder", controllerBuilder);
        }
    }

}
